import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/style/variables.scss" as *;`,
      },
    },
  },
  server: {
    proxy: {
      '/dev-api': {
        target: 'http://127.0.0.1:18080', // 后端服务地址
        changeOrigin: true, // 支持跨域
        secure: false, // 如果是 https 接口，需要配置这个参数
        rewrite: (path) => path.replace(/^\/dev-api/, ''), // 重写路径，去掉 /api 前缀
      },
      '/production-api': {
        target: ' http://jwcb-jwcb-gateway-1:18080',
         changeOrigin: true, // 支持跨域
        secure: false, // 如果是 https 接口，需要配置这个参数
        rewrite: (path) => path.replace(/^\/production-api/, ''), // 重写路径，去掉 /api 前缀
      }
    }
  }
})
